package com.supermali.entity.map.hinder;

import com.supermali.creater.MapCreater;
import com.supermali.creater.img.ImgHelper;
import com.supermali.creater.img.ImgKey;
import com.supermali.creater.img.ImgLoader;
import com.supermali.entity.map.background.dynamic.ThinCoin;

import java.awt.image.BufferedImage;
import java.util.List;

/**
 * @project super-mali
 * @Date 2021/2/28
 * @Auth yangrui
 **/
public class Question extends HinderMapAbstract {

    public Question(Double x, Double y, MapCreater mapCreater) {
        super(x, y, mapCreater);
    }

    @Override
    public void init() {
        ImgHelper imgHelper = ImgLoader.getImgHelper(ImgKey.Hinder.QUESTION);
        BufferedImage select = imgHelper.select(0);
        this.setBufferedImage(select);
    }

    /**
     * 销毁方法，默认顶出金币特效
     * */
    @Override
    public void destroy(long delta) {
        // 转成实体块
        List<HinderMapAbstract> hinderMap = getMapCreater().getHinderMapAbstracts();
        hinderMap.remove(this);
        HitQuestion floor = new HitQuestion(getX(), getY(), getMapCreater());
        hinderMap.add(floor);
        // 增加金币特效
        ThinCoin thinCoin = new ThinCoin(this.getX()+this.getBufferedImage().getWidth()/2, this.getY(), getMapCreater());
        thinCoin.getUpMiss().start();
        getMapCreater().getDynamicBackgroundAbstracts().add(thinCoin);
    }
}
